<?php
include_once 'app/until/GFW_database.php';

class GFW_Validate {

	protected  $con = null;
	protected  $user_id = null;
	private $username;

	function __construct(){

	}
	public static function ValidateFile($content,$tmp = false){
		if(preg_match ('(print_r\(|print\(|echo|[$]|<\?|<php+)', $content)){
			if($tmp){
				unlink($tmp);
			}
			return false;
		}else{
			if (preg_match ('([\{}]+)', $content)){
				return true;
			}else{
				if($tmp){
					unlink($tmp);
				}
				return false;
			}
		}
	}
    public static function ConvertBBcode($content){
        
        $bbcode = array(
        
        "/\[b\](.*?)\[\/b\]/is" => "<strong>$1</strong>",
        "/\[u\](.*?)\[\/u\]/is" => "<u>$1</u>",
        "/\[i\](.*?)\[\/i\]/is" => "<i>$1</i>", 
        "/\[img\](.*?)\[\/img\]/is" => "<img src='../$1' />",       
        "/\[color\=(.*?)\](.*?)\[\/color\]/is" => "<span style='color: $1'>$2</span>",
        "/\[url\=(.*?)\](.*?)\[\/b\]/is" => "<a href='$1'>$2</a>"
        
        );
        
        $text = preg_replace(array_keys($bbcode), array_values($bbcode), $content);
              
        return $text;
    }
}
?>